package com.flxz.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.flxz.common.annotation.Log;
import com.flxz.common.core.controller.BaseController;
import com.flxz.common.core.domain.AjaxResult;
import com.flxz.common.enums.BusinessType;
import com.flxz.manage.domain.UserCheckinAdmin;
import com.flxz.manage.service.IUserCheckinAdminService;
import com.flxz.common.utils.poi.ExcelUtil;
import com.flxz.common.core.page.TableDataInfo;

/**
 * 用户签到（管理员）Controller
 * 
 * @author fl
 * @date 2025-09-12
 */
@RestController
@RequestMapping("/manage/checkinAdmin")
public class UserCheckinAdminController extends BaseController
{
    @Autowired
    private IUserCheckinAdminService userCheckinAdminService;

    /**
     * 查询用户签到（管理员）列表
     */
    @PreAuthorize("@ss.hasPermi('manage:checkinAdmin:list')")
    @GetMapping("/list")
    public TableDataInfo list(UserCheckinAdmin userCheckinAdmin)
    {
        startPage();
        List<UserCheckinAdmin> list = userCheckinAdminService.selectUserCheckinAdminList(userCheckinAdmin);
        return getDataTable(list);
    }

    /**
     * 导出用户签到（管理员）列表
     */
    @PreAuthorize("@ss.hasPermi('manage:checkinAdmin:export')")
    @Log(title = "用户签到（管理员）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UserCheckinAdmin userCheckinAdmin)
    {
        List<UserCheckinAdmin> list = userCheckinAdminService.selectUserCheckinAdminList(userCheckinAdmin);
        ExcelUtil<UserCheckinAdmin> util = new ExcelUtil<UserCheckinAdmin>(UserCheckinAdmin.class);
        util.exportExcel(response, list, "用户签到（管理员）数据");
    }

    /**
     * 获取用户签到（管理员）详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:checkinAdmin:query')")
    @GetMapping(value = "/{checkinId}")
    public AjaxResult getInfo(@PathVariable("checkinId") String checkinId)
    {
        return success(userCheckinAdminService.selectUserCheckinAdminByCheckinId(checkinId));
    }

    /**
     * 新增用户签到（管理员）
     */
    @PreAuthorize("@ss.hasPermi('manage:checkinAdmin:add')")
    @Log(title = "用户签到（管理员）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UserCheckinAdmin userCheckinAdmin)
    {
        return toAjax(userCheckinAdminService.insertUserCheckinAdmin(userCheckinAdmin));
    }

    /**
     * 修改用户签到（管理员）
     */
    @PreAuthorize("@ss.hasPermi('manage:checkinAdmin:edit')")
    @Log(title = "用户签到（管理员）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UserCheckinAdmin userCheckinAdmin)
    {
        return toAjax(userCheckinAdminService.updateUserCheckinAdmin(userCheckinAdmin));
    }

    /**
     * 删除用户签到（管理员）
     */
    @PreAuthorize("@ss.hasPermi('manage:checkinAdmin:remove')")
    @Log(title = "用户签到（管理员）", businessType = BusinessType.DELETE)
	@DeleteMapping("/{checkinIds}")
    public AjaxResult remove(@PathVariable String[] checkinIds)
    {
        return toAjax(userCheckinAdminService.deleteUserCheckinAdminByCheckinIds(checkinIds));
    }
}
